﻿using System.Windows.Input;
using Microsoft.Practices.Prism.Commands;
using SilverMindMap.Core.Model;

namespace SilverMindMap.Core.ViewModel
{
    public class NodeViewModel : ViewModel
    {
        private readonly Node _node;
        private readonly DelegateCommand _setAsRootNodeCommand;
        
        public NodeViewModel(Node node)
        {
            Guard.ArgumentNotNull(node, "node");

            _node = node;
            _setAsRootNodeCommand = new DelegateCommand(ExecuteSetAsRootNodeCommand);
        }

        public Node Node
        {
            get { return _node; }
        }

        public ICommand SetAsRootNodeCommand
        {
            get { return _setAsRootNodeCommand; }
        }

        private void ExecuteSetAsRootNodeCommand()
        {
            _node.MindMap.RootNode = _node;
        }
    }
}
